import os from "os";
export default {
  getLocalIp() {
    const networkInterfaces = os.networkInterfaces();
    // console.log(networkInterfaces);
    const ipv4NetworkInterfaces = Object.keys(networkInterfaces)
      .filter((networkKey) => {
        const networks = networkInterfaces[networkKey];
        return networks.some((network) => {
          return network.family.toUpperCase() === "IPV4";
        });
      })
      .map((networkKey) => {
        const networks = networkInterfaces[networkKey].filter(
          (item) => item.family.toUpperCase() === "IPV4"
        );
        return networks[0].address;
      });
    return ipv4NetworkInterfaces;
  },
};
